<?php

namespace backend\controllers\auth;

use mdm\admin\components\Helper;
use mdm\admin\models\AuthItem;
use mdm\admin\models\BizRule;

/**
 * Class RuleController
 * @package backend\controllers\auth
 */
class RuleController extends \mdm\admin\controllers\RuleController
{

    /**
     * actionCreate
     * @return mixed|string|\yii\web\Response
     */
    public function actionCreate()
    {
        $model = new BizRule(null);
        if ($model->load(post()) && $model->save()) {
            Helper::invalidate();
            return $this->redirect(['index']);
        } else {
            return $this->render('create', ['model' => $model,]);
        }
    }

    /**
     * actionUpdate
     * @param string $id
     * @return mixed|string|\yii\web\Response
     */
    public function actionUpdate($id)
    {
        /** @var AuthItem $model */
        $model = $this->findModel($id);
        if ($model->load(post()) && $model->save()) {
            Helper::invalidate();
            return $this->redirect(['index']);
        }

        return $this->render('update', ['model' => $model,]);
    }

}
